package com.jz.cash.client.service.impl;

import com.jz.cash.client.dao.MenuConfigDao;
import com.jz.cash.client.entity.MenuConfig;
import com.jz.cash.client.service.MenuConfigService;
import com.jz.cash.client.service.MerchantService;
import com.jz.cash.client.vo.MenuVo;
import com.jz.cash.client.vo.MerchantVo;
import com.stip.mybatis.generator.plugin.BaseExample;
import com.stip.mybatis.generator.plugin.BaseService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Set;

@Service
@Slf4j
public class MenuConfigServiceImpl extends BaseService<MenuConfig, BaseExample, Long> implements MenuConfigService {

    @Autowired
    private MerchantService merchantService;

    @Autowired
    private MenuConfigDao menuConfigDao;

    @Override
    public Set<MenuVo> findMenuListByUserId(Long userId) {
        log.debug("INTO find menu list by userId");

        MerchantVo byUserId = merchantService.findByUserId(userId);

        return menuConfigDao.findMenuListByMerchantId(byUserId.getMerchantId());
    }
}